﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SysCommon.Tools
{
    public class MathTools
    {
        public static bool IsNumber(string str)
        {
            try
            {
                if (str == null) return false;
                int i = 0;
                foreach (char c in str)
                {
                    if (char.IsNumber(c))
                    {
                        continue;
                    }
                    else
                    {
                        if (c == '.' && i == 0)
                        {
                            i++;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        public static bool IsIntegerNumber(string str)
        {
            try
            {
                if (str == null) return false;
                if (str.Equals(string.Empty)) return false;
                int i = 0;
                foreach (char c in str)
                {
                    if (char.IsNumber(c))
                    {
                        continue;
                    }
                    else
                    {
                        return false;
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }
}
